﻿using Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Bussiness.Service;
using System.Web.UI.WebControls;
using Common.Model;

public partial class BookDetail : System.Web.UI.Page
{
    BookService bookService = new BookService();
    Users user = new Users();
    public string BookName, BookID, BookAuthor, BookPrice, BookImageID;
    protected void Page_Load(object sender, EventArgs e)
    {
        user = (Users)Session["user"];
        BookName = Request.Params["BookName"];//图书名
        BookID = Request.Params["BookID"];
        BookAuthor = Request.Params["BookAuthor"];//作者
        BookPrice = Request.Params["BookPrice"];//价格
        BookImageID = Request.Params["BookImageId"];
        Book_name1.InnerText = BookName;//赋值给页面书名
        Book_name2.InnerText = BookName;
        Book_name3.InnerText = BookName;
        Book_Author.InnerText = "作者：" + BookAuthor;
        Book_Author2.InnerText = "作者：" + BookAuthor;
        Book_Price.InnerText = "￥" + BookPrice;
        string url = @"Bimage/" + BookImageID + ".jpg";
        BookImageId1.InnerHtml = "<div style ='margin-left: 50px; background-image:url(" + url + ");background-size: contain; width:112px ;height:160px'></div>";
        BookImageId2.InnerHtml = "<div style='background-image:url(" + url + ");background-size: contain; width:58px;height: 78px;'></div>";
    }

    protected void Unnamed_ServerClick(object sender, EventArgs e)//加入购物车事件
    {
        if (Session["user"] != null)
        {
            if (bookService.BookCop(BookID, user.UserID, 1, Common.Enums.BookingStatus.JoinCar).Success)
            {
                
                Response.Write("<script>alert('加入购物车成功')</script>");
            }
            else
            {
                Response.Write("<script>alert('加入购物车失败')</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('请先去登录')</script>");
        }
    }

    protected void Unnamed_ServerClick1(object sender, EventArgs e)//加入我的愿望单事件
    {
        if (Session["user"] != null)
        {
            if (bookService.BookCop(BookID, user.UserID, 1, Common.Enums.BookingStatus.Like).Success)
            {
                Response.Write("<script>alert('成功添加到您的愿望单')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加到您的愿望单失败')</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('请先去登录')</script>");
        }
    }
}